package alkaid.eis.sys.entity;

import java.util.Comparator;

/**
 * 部门排序
 *  
 * @author Lucky Yang
 * @since 0.0.1
 */
public class DeptComparator {
    public final static OrderNoAndNameComparator ORDERNO_NAME = new OrderNoAndNameComparator();
    public final static PathIdComparator PATHID = new PathIdComparator();

    public static class OrderNoAndNameComparator implements Comparator<Dept> {
        @Override
        public int compare(Dept o1, Dept o2) {
            Integer order1 = o1.getOrderNo() == null ? Integer.MAX_VALUE : o1.getOrderNo();
            Integer order2 = o2.getOrderNo() == null ? Integer.MAX_VALUE: o2.getOrderNo();

            int rslt = order1.compareTo(order2);
            if (rslt == 0) {
                return o1.getName().compareTo(o2.getName());
            }

            return rslt;
        }
    }

    public static class PathIdComparator implements Comparator<Dept> {
        @Override
        public int compare(Dept o1, Dept o2) {
            String order1 = o1.getPathId() == null ? "" : o1.getPathId();
            String order2 = o2.getPathId() == null ? "" : o2.getPathId();

            return order1.compareTo(order2);
        }
    }
}
